using IcsSEMCtrl.Util;
namespace Lifter.Global.Device
{
    public class AbnormalType
    {
        public const int _NORMAL = 0;
        public const int _FAULT = 1;
        public const int _SOURCE_ABNORMAL = 2;
        public const int _DEST_ABNORMAL = 3;
        private int _value;
        private static int _size;
        private static AbnormalType[] _array;
        public static string[] displayStrings;
        public static AbnormalType[] displayValues;
        public static AbnormalType NORMAL;
        public static AbnormalType FAULT;
        public static AbnormalType SOURCE_ABNORMAL;
        public static AbnormalType DEST_ABNORMAL;
        public static AbnormalType IT_ENUM_MAX;
        static AbnormalType()
        {
            AbnormalType._size = 4;
            AbnormalType._array = new AbnormalType[AbnormalType._size];
            AbnormalType.displayStrings = new string[AbnormalType._size];
            AbnormalType.displayValues = new AbnormalType[AbnormalType._size];
            AbnormalType.NORMAL = new AbnormalType(0);
            AbnormalType.FAULT = new AbnormalType(1);
            AbnormalType.SOURCE_ABNORMAL = new AbnormalType(2);
            AbnormalType.DEST_ABNORMAL = new AbnormalType(3);
            AbnormalType.IT_ENUM_MAX = new AbnormalType(2147483647);
            AbnormalType.displayStrings[0] = "NORMAL";
            AbnormalType.displayStrings[1] = "FAULT";
            AbnormalType.displayStrings[2] = "SOURCE_ABNORMAL";
            AbnormalType.displayStrings[3] = "DEST_ABNORMAL";
            AbnormalType.displayValues[0] = AbnormalType.NORMAL;
            AbnormalType.displayValues[1] = AbnormalType.FAULT;
            AbnormalType.displayValues[2] = AbnormalType.SOURCE_ABNORMAL;
            AbnormalType.displayValues[3] = AbnormalType.DEST_ABNORMAL;
        }
        public static string ValueToString(AbnormalType val)
        {
            string result;
            switch (val.Value())
            {
                case 0:
                    result = AbnormalType.displayStrings[0];
                    break;
                case 1:
                    result = AbnormalType.displayStrings[1];
                    break;
                case 2:
                    result = AbnormalType.displayStrings[2];
                    break;
                case 3:
                    result = AbnormalType.displayStrings[3];
                    break;
                default:
                    result = "";
                    break;
            }
            return result;
        }
        public static AbnormalType StringToValue(string val)
        {
            AbnormalType result;
            if (Helper.IsNullOrEmpty(val))
            {
                result = AbnormalType.IT_ENUM_MAX;
            }
            else
            {
                for (int i = 0; i < AbnormalType.displayStrings.Length; i++)
                {
                    if (val.Equals(AbnormalType.displayStrings[i]))
                    {
                        result = AbnormalType.displayValues[i];
                        return result;
                    }
                }
                result = null;
            }
            return result;
        }
        public int Value()
        {
            return this._value;
        }
        public static AbnormalType From_Int(int value)
        {
            AbnormalType result;
            if (value >= 0 && value < AbnormalType._size)
            {
                result = AbnormalType._array[value];
            }
            else
            {
                result = AbnormalType.IT_ENUM_MAX;
            }
            return result;
        }
        protected AbnormalType(int value)
        {
            this._value = value;
            if (value >= 0 && value < AbnormalType._size)
            {
                AbnormalType._array[this._value] = this;
            }
        }
        public bool Equals(AbnormalType otherEnum)
        {
            return otherEnum.Value() == this._value;
        }
        public override string ToString()
        {
            return AbnormalType.displayStrings[this._value];
        }
    }
}
